package cs2114.antiFingerMines;

import student.TestCase;

// -------------------------------------------------------------------------
/**
 *  This class tests the Mine class.
 *
 * @author Blake Whaley
 * @author Graham McLaughlin (gjm1324)
 * @author William Vuong (wnvuong)
 * @version 2012.29.4
 */
public class MineTest
    extends TestCase
{
    /**
     * First Mine
     */
    Mine newMine;
    /**
     * Second mine
     */
    Mine newMine2;
    /**
     * MineField
     */
    MineField field = new MineField(480, 480, 10);

    /**
     * Sets up the mine to be tested
     */
    public void setUp()
    {
        newMine = new Mine(3, 3, 5);
        newMine2 = new Mine(1, 1, 2);
    }

    /**
     * Tests the getX, getY, and getRadius
     */
    public void testGetXandGetY()
    {
        assertEquals(3.0, newMine.getX(), .000001);
        assertEquals(5.0, newMine.getRadius(), .00001);
    }

    /**
     * Tests distanceFrom both mine and x, y inputs
     */
    public void testDistanceFrom()
    {
        assertEquals(0, newMine.distanceFrom(newMine), .00001);
        assertEquals(2.82843, newMine.distanceFrom(newMine2), .00001);
        assertEquals(2.82843, newMine.distanceFrom(1, 1), .00001);
        assertEquals(2.82843, newMine2.distanceFrom(3, 3), .00001);

        field.setFingerLocation(0, 0);
        assertEquals(1.41421356, newMine2.distanceFrom(field.finger), .00001);
    }

    /**
     * Tests the traversable distance
     */
    public void testTraversableDistance()
    {
        assertEquals(-4.17157,
            newMine.traversableDistanceBetween(newMine2), .00001);
        assertEquals(-4.17157,
            newMine2.traversableDistanceBetween(newMine), .00001);
    }

    /**
     * Tests the distance from blast
     */
    public void testDistanceFromBlast()
    {
        assertEquals(-2.17157, newMine.distanceFromBlast(1, 1), .00001);
    }

    /**
     * Tests the to string method
     */
    public void testToString()
    {
        assertEquals("3.0, 3.0, 5.0", newMine.toString());
    }
}
